﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System.ServiceModel.DomainServices.Server;
using System.Text;
#endregion

namespace NetBay.Core.BusinessEntities
{
    /// <summary>
    /// DATABASE TABLENAME : r_group
    /// </summary>
    [DataContract]
    public class Group : ReturnObject
    {
        #region Private members

        /// <summary>
        /// The entity associated
        /// </summary>
        private List<Organization> m_lstOrganization = new List<Organization>();

        /// <summary>
        /// List of itemRights
        /// </summary>
        private List<ItemRights> m_lstItemRights = new List<ItemRights>();

        /// <summary>
        /// List of FolderTypeRight
        /// </summary>
        private List<FolderType> m_lstFolderTypeRightList = new List<FolderType>();

        #endregion

        #region Properties

        [DataMember]
        public long UserIdentifier { get; set; }

        [Association("OrganizationList", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public List<Organization> OrganizationList
        {
            get { return m_lstOrganization; }
            set 
            { 
                m_lstOrganization = value;
                ItemEntity.SetForeignKey(m_lstOrganization, Key);
            }
        }

        [DataMember]
        public bool CanDownload { get; set; }

        [DataMember]
        public bool CanPrint { get; set; }

        [DataMember]
        public bool CanScann { get; set; }

        [DataMember]
        public bool CanScanExtended { get; set; }

        [DataMember]
        public bool CanConsultExtended { get; set; }

        [DataMember]
        public bool CanAnnotate { get; set; }

        [DataMember]
        public bool CanReorganize { get; set; }

        [DataMember]
        public bool IsAdministrator { get; set; }

        [DataMember]
        public bool CanSendEmail { get; set; }

        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public long Identifier { get; set; }

        [DataMember]
        public bool CanConsult { get; set; }

        [DataMember]
        public bool CanFlow { get; set; }

        [DataMember]
        public bool CanMassImport { get; set; }

        [DataMember]
        public bool CanDelete { get; set; }

        [DataMember]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the can flow validation.
        /// </summary>
        /// <value>The can flow validation.</value>
        [DataMember]
        public bool CanFlowValidation { get; set; }

        /// <summary>
        /// Gets or sets the is user.
        /// </summary>
        /// <value>The is user.</value>
        [DataMember]
        public bool IsUser { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance can remove.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance can remove; otherwise, <c>false</c>.
        /// </value>
        [DataMember]
        public bool CanTrash { get; set; }


        #endregion

        [Association("ItemRightsList", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public List<ItemRights> ItemRightsList
        {
            get { return m_lstItemRights; }
            set 
            {
                m_lstItemRights = value;
                ItemEntity.SetForeignKey(m_lstItemRights, Key);
            }
        }

        [Association("FolderType", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public List<FolderType> FolderTypeRigthList
        {
            get { return m_lstFolderTypeRightList; }
            set
            {
                m_lstFolderTypeRightList = value;
                ItemEntity.SetForeignKey(m_lstFolderTypeRightList, Key);
            }
        }

        public override object Clone()
        {
            throw new NotImplementedException();
        }

        #region ToString
        /// <summary>
        /// Extend default description of class
        /// </summary>
        /// <returns>description of instance</returns>
        public override string ToString()
        {
            StringBuilder parameters = new StringBuilder("Identifier<", 4096);
            parameters.Append(Identifier); parameters.Append("> ");
            parameters.Append("Name<"); parameters.Append(Name); parameters.Append("> ");

            return parameters.ToString();
        }
        #endregion

    }

    public abstract class GroupDer : Group 
    {
        public abstract void SetOrganizationList(long p_lUserId);
        public abstract void SetItemRightsList(long p_lUserId);
        public abstract void SetFolderTypeRightList(long p_lUserId);
    }
}
